<template>
  <div v-if="$store.state.buyTicket.promptAlert" class="prompt-bag cenCen" @click.self="$store.state.buyTicket.promptAlert=false">
    <!-- <transition name="bounce"> -->
    <div v-if="$store.state.buyTicket.promptAlert" class="prompt-box">
      <div class="prompt-title">
        开售提醒
      </div>
      <div class="prompt-con">
        <p>请留下你的常⽤联系⼿机号</p>
        <p>以便能在开售前1小时短信提醒您</p>
      </div>
      <div class="prompt-input cenCen">
        <div class="prompt-input-tit cenCen">+{{areaCode}}
          <co-select v-model.trim="areaCode" title="电话国家码" search-placeholder="请输入" type="popup" :data="selectList" placeholder="请输入" class="prompt-co-select" />
        </div>
        <input v-model.trim="uTel" maxlength="13" placeholder="请输入手机号">
      </div>
      <div class="prompt-btn-box">
        <div class="prompt-btn cenCen" @click="$store.state.buyTicket.promptAlert=false">
          取消
        </div>
        <div class="prompt-btn cenCen prompt-btn-sure" @click="reminderSale()">
          确认
        </div>
      </div>
    </div>
    <!-- </transition> -->
  </div>
</template>
<script>
import areaCodeList from "./../../../infoEntry/areaCode.json"; //区号json
// 接口服务
import buyTicketService from "./../../../../api/buyTicketService.js";
export default {
  data() {
    return {
      selectList: [], //选项
      areaCode: "86", //区域号
      uTel: "" //手机号
    };
  },
  created() {
    this.selectList = [];
    for (let i = 0; i < areaCodeList.length; i++) {
      let obj = {
        label: `${areaCodeList[i].name}(${areaCodeList[i].tel})`,
        value: areaCodeList[i].tel
      };
      this.selectList.push(obj);
    }
  },
  methods: {
    reminderSale() {
      if (!this.uTel) {
        this.$toast("请输入手机号");
        return;
      }
      if (!this.check_phone(this.uTel)) {
        this.$toast("请输入正确的手机号");
        this.uTel = "";
        return;
      }

      this.$store.state.loading = true;
      buyTicketService
        .reminderSale(
          this.areaCode,
          this.uTel,
          this.$store.state.buyTicket.activityId
        )
        .then(res => {
          this.$store.state.loading = false;
          if (res.success) {
            this.$toast("预约成功");
            this.$store.state.buyTicket.promptAlert = false;
          } else {
            // this.$toast(res.errorMsg);
          }
        });
    },
    //验证电话号码
    check_phone(phoneNum) {
      return /^1[0-9]{10}$/.test(phoneNum);
    }
  }
};
</script>


<style scoped>
.prompt-bag {
  position: fixed;
  left: 0px;
  top: 0px;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
}
.prompt-box {
  width: 60%;
  max-width: 460px;
  height: auto;
  min-height: 200px;
  background: #e0e0e0;
  border-radius: 14px;
  padding: 16px 30px 120px 30px;
  position: relative;
}
.prompt-title {
  width: 100%;
  height: auto;
  /* font-family: PingFangSC-Semibold; */
  font-size: 28px;
  color: #000000;
  letter-spacing: 0;
  text-align: center;
  margin: 20px 0px;
}
.prompt-con {
  width: 100%;
  height: auto;
  text-align: center;
  margin: 10px 0px;
}
.prompt-con > p {
  /* font-family: PingFangSC-Regular; */
  font-size: 22px;
  color: #373d41;
  letter-spacing: 0;
  text-align: center;
  margin: 3px 0px;
}
.prompt-input {
  width: 100%;
  height: 54px;
  line-height: 54px;
  background: #ffffff;
  border-radius: 2px;
  position: relative;
}
.prompt-input-tit {
  position: absolute;
  left: 0px;
  top: 0px;
  width: 90px;
  height: 100%;
  font-size: 22px;
  color: #373d41;
  padding: 0px 8px;
  cursor: pointer;
}
.prompt-co-select {
  position: absolute;
  left: 0px;
  top: 0px;
  width: 90px;
  height: 100%;
  cursor: pointer !important;
}
.co-input::after {
  border: none !important;
  height: 0px !important;
}
.prompt-input > input {
  width: 100%;
  height: 100%;
  text-align: left;
  font-size: 22px;
  color: #373d41;
  padding: 0px 16px 0px 96px;
}
.prompt-btn-box {
  position: absolute;
  left: 0px;
  bottom: 0px;
  width: 100%;
  height: 88px;
  cursor: pointer;
  border-top: 1px solid rgba(0, 0, 80, 0.9);
}
.prompt-btn {
  width: 50%;
  height: 100%;
  float: left;
  /* font-family: PingFangSC-Medium; */
  font-size: 28px;
  color: #007aff;
}
.prompt-btn-sure {
  border-left: 1px solid rgba(0, 0, 80, 0.9);
}

/* 动画 */
/* 
.bounce-enter-active {
  animation: bounce-in 0.4s;
}

.bounce-leave-active {
    animation: bounce-in 0.4s reverse;
  }
@keyframes bounce-in {
  0% {
    transform: scale(0);
  }

  10% {
    transform: scale(0.2);
  }

  20% {
    transform: scale(0.3);
  }

  30% {
    transform: scale(0.4);
  }

  40% {
    transform: scale(0.4);
  }

  50% {
    transform: scale(0.5);
  }

  60% {
    transform: scale(0.6);
  }

  70% {
    transform: scale(0.7);
  }

  80% {
    transform: scale(0.8);
  }

  90% {
    transform: scale(0.9);
  }

  100% {
    transform: scale(1);
  }
} */
</style>

